﻿using System;

// 动物抽象类
abstract class Animal
{
    public abstract void Voice();
}

// Cat类
class Cat : Animal
{
    public override void Voice() => Console.WriteLine("猫：喵喵喵");
}

// Pig类
class Pig : Animal
{
    public override void Voice() => Console.WriteLine("猪：哼哼哼");
}

// Dog类
class Dog : Animal
{
    public override void Voice() => Console.WriteLine("狗：汪汪汪");
}

// 宠物店类（工厂模式）
class Store
{
    public static Animal GetInstance(string type)
    {
        switch (type.ToLower())
        {
            case "dog":
                return new Dog();
            case "pig":
                return new Pig();
            default:
                return new Cat();
        }
    }
}

// 测试类
class Program
{
    static void Main(string[] args)
    {
        Animal animal1 = Store.GetInstance("dog");
        animal1.Voice();

        Animal animal2 = Store.GetInstance("pig");
        animal2.Voice();

        Animal animal3 = Store.GetInstance("other");
        animal3.Voice();
    }
}
